#ifndef _CHARSETCONVERT_H_
#define _CHARSETCONVERT_H_

#include <nsCOMPtr.h>
#include "nsIScriptableUConv.h"
#include <string>
#include "nsStringAPI.h"

// convert fileEncode to Unicode
// convert Unicode to local set;
class CCharsetConvert
{
public:
	static CCharsetConvert& GetIns()
	{
		return ins;
	}

	~CCharsetConvert(void);

	void SetFileEncode(const std::string &encode);
	void SetLocal(const std::string &encode);
	std::string GetLocal();

	nsString ConvertToUnicode(const nsACString &in);
	nsCString ConvertToLocal(const nsAString &in);

	std::string DetectEncode(const std::string &file);
	std::string ConvertUTF16ToUTF8(const std::string &file);

private:
	CCharsetConvert(void);
	static CCharsetConvert ins;

	nsCOMPtr<nsIScriptableUnicodeConverter> m_converter;
	std::string m_fileEncode;
	std::string m_local;
};

#endif

